Object

Vector3D Class

Used to represent absolute or relative position of a vector an RB3DSpace three-dimensional space.

Properties

X

Y

Z

Methods

Add

Minus

Copy

MultiplyBy

Cross

Normalize

Dot

Plus

Length

Subtract

LenSquared

Times

Notes


Constructor Syntaxes

Syntax

Parameters

Description

New Vector3D(x, y, z)

x as Double y as Double z as Double

Creates a Vector3D and initializes x, y, and z to the values passed.

New Vector3D(vec)

vec as Vector3D

Creates a Vector3D and initializes the new vector to the same value as the one given.



The Vector3D class is used to represent absolute or relative position in Rb3DSpace. It is simply the X, Y, and Z coordinates of a point in 3D space. Depending on how you intend to use it, they can either mean the absolute position of something in 3D space, or a change in position. You can get its length (i.e., its distance from the origin), or is squared length (which is cheaper to compute). Normalize() scales the vector so that its length becomes 1. The Cross and Dot methods allow you to perform two kinds of vector multiplication.

Comparison of Vector Operations

The Vector3D class has a complete set of methods for performing vector arithmetic, eliminating the need work with the individual elements of the vectors. You may either save the result of the operation in the calling vector or save the result in a new vector. The following table compares the six methods.

Operation

Save result in place

Save result in a new vector

Addition

a.Add(b)

c = a.Plus(b)

Subtraction

a.Subtract(b)

c = a.Minus(b)

Scaling

a.MultiplyBy(f)

c = a.Times(f)



See Also

Bounds3D, ColorList, Element3D, Group3D, Light3D, Material, Object3D, Quaternion, TriangleList, Trimesh, UVList, Vector3D, VectorList classes; RB3DSpace control.